package com.qlh.camera.rgb

import org.opencv.core.Mat
import org.opencv.imgcodecs.Imgcodecs
import java.text.DecimalFormat

object ThresholdUtil {

    fun getMT(imgPath: String): Double {
        //获取RGB
        val df = DecimalFormat("##0.00")
        val image = Imgcodecs.imread(imgPath)
        val meanStdDev = ImageUtil.getRGBMeanStdDev(image)
        val mt = df.format((meanStdDev.b.mean - meanStdDev.r.mean) / (meanStdDev.b.mean - meanStdDev.g.mean))
        println("成熟度系数:$mt")
        return mt.toDouble()
    }


    fun getMT(image: Mat): Double {
        //获取RGB
        val df = DecimalFormat("##0.00")
        val meanStdDev = ImageUtil.getRGBMeanStdDev(image)
        val mt = df.format((meanStdDev.b.mean - meanStdDev.r.mean) / (meanStdDev.b.mean - meanStdDev.g.mean))
        println("成熟度系数:$mt")
        return mt.toDouble()
    }


}